package reflect;

import java.util.Scanner;

public class ReflectDemo2 {
    public static void main(String[] args) throws ClassNotFoundException, IllegalAccessException, InstantiationException {
        Person p = new Person();
        System.out.println(p);

        //加载需要实例化对象的类的类对象
//        Class cls =
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入包名");
        String str =scanner.nextLine();
        Class cls = Class.forName(str);
        System.out.println(cls);
        //类对象提供了方法：newInstance()可以利用其表示的类的公开的无参构造器实例化
        Object obj = cls.newInstance();
        System.out.println(obj);
    }
}
